<template>
    <search-nav />
    <div class="w container">
        <div class="chat--container">
            <div class="chat--title">
                <span>联系客服</span>
                <span>在线实时沟通，快速解决您的问题</span>
            </div>
            <div class="chat--body">
                <div v-for="(item, index) in messageList">
                    <!-- 管理员 -->
                    <div class="chat--message" v-if="item.role === 'admin'">
                        <img src="@/assets/img/Customer-Service.png" alt="" width="48px" height="48px" />
                        <div class="message--box">
                            <div class="message--time">{{ item.time }}</div>
                            <div class="message--content">{{ item.msg }}</div>
                        </div>
                    </div>
                    <!-- 用户 -->
                    <div class="chat--message chat--message--my" v-else>
                        <img src="@/assets/img/Customer.png" alt="" width="48px" height="48px" />
                        <div class="message--box">
                            <div class="message--time">{{ item.time }}</div>
                            <div class="message--content">{{ item.msg }}</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="chat--send">
                <input type="text" />
                <button>发送</button>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref } from 'vue';
import searchNav from '@/components/search-nav.vue';

let messageList = ref([
    {
        time: '05-06 14:24:51',
        role: 'admin',
        msg: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam porro non sequi facilis officiis vitae ipsam provident eos, iusto blanditiis beatae optio in iste sapiente? Delectus placeat veritatis perspiciatis architecto.',
    },
    {
        time: '05-06 14:24:51',
        role: 'user',
        msg: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam porro non sequi facilis officiis vitae ipsam provident eos, iusto blanditiis beatae optio in iste sapiente? Delectus placeat veritatis perspiciatis architecto.',
    },
    {
        time: '05-06 14:24:51',
        role: 'admin',
        msg: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam porro non sequi facilis officiis vitae ipsam provident eos, iusto blanditiis beatae optio in iste sapiente? Delectus placeat veritatis perspiciatis architecto.',
    },
    {
        time: '05-06 14:24:51',
        role: 'admin',
        msg: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam porro non sequi facilis officiis vitae ipsam provident eos, iusto blanditiis beatae optio in iste sapiente? Delectus placeat veritatis perspiciatis architecto.',
    },
    {
        time: '05-06 14:24:51',
        role: 'user',
        msg: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam porro non sequi facilis officiis vitae ipsam provident eos, iusto blanditiis beatae optio in iste sapiente? Delectus placeat veritatis perspiciatis architecto.',
    },
    {
        time: '05-06 14:24:51',
        role: 'user',
        msg: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam porro non sequi facilis officiis vitae ipsam provident eos, iusto blanditiis beatae optio in iste sapiente? Delectus placeat veritatis perspiciatis architecto.',
    },
]);
</script>

<style lang="scss" scoped>
// 聊天区
.chat--container {
    display: flex;
    flex-direction: column;
    height: 84vh;
    background-color: #f7f9fa;
    position: relative;
}
.chat--title {
    position: sticky;
    height: 20px;
    padding: 8px;
    border: 1px solid #e6e8e9;
    border-top: 1px solid #0064cb;
    background-color: #fff;
    box-shadow: 0 5px 10px -5px rgba(0, 0, 0, 0.15);
    // border: 1px solid red;
    span:first-child {
        font-weight: 600;
        font-size: 14px;
    }
    span:last-child {
        margin-left: 12px;
        font-size: 12px;
        color: #888;
    }
}
.chat--body {
    height: 100%;
    padding: 10px;
    overflow-y: auto;
    border-bottom: 1px solid #e6e6e6;
}

// 客服
.chat--message {
    margin-bottom: 10px;
    display: flex;
    img {
        margin-right: 12px;
    }
    .message--time {
        font-size: 12px;
        height: 20px;
        line-height: 20px;
        margin-left: 8px;
        // border: 1px solid red;1
        color: #888;
    }
    .message--content {
        // border: 1px solid red;
        background-color: #fff;
        padding: 10px;
        margin-bottom: 10px;
        max-width: 600px;
        font-size: 14px;
        font-weight: 500;
        border-radius: 8px;
        // line-height: 18px;
        box-sizing: border-box;
    }
}

// 用户
.chat--message--my {
    flex-direction: row-reverse;
    img {
        margin-left: 12px;
        margin-right: 0px;
    }
    .message--time {
        text-align: right;
        margin-right: 8px;
    }
}
.chat--send {
    height: 140px;
    input {
        width: 700px;
        outline: none;
        border: none;
        text-indent: 4px;
    }
}
</style>
